/*
 * This file is part of aKoustiK.

 * aKoustiK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * aKoustiK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with aKoustiK.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <KGlobal>
#include <KIcon>
#include <KLocale>
#include <KSharedConfig>
#include <KSharedConfigPtr>

#include <QtCore/QDebug>
#include <QtGui/QDockWidget>
#include <QtGui/QSplitter>

#include <ui/mainwindow.h>
#include <ui/filebrowser/filebrowser.h>
#include <ui/player/playerwidget.h>
#include <ui/playlists/playlistswidget.h>

MainWindow::MainWindow() : KMainWindow() {
    qDebug("MainWindow: constructor invoked");
    setWindowIcon(KIcon("preferences-desktop-sound"));

    QDockWidget* browserDock = new QDockWidget(i18n("File Browser"), this);
    browserDock->setWidget(new FileBrowser(this));
    addDockWidget(Qt::LeftDockWidgetArea, browserDock);

    QSplitter* splitter = new QSplitter(Qt::Horizontal, this);
    splitter->addWidget(new PlayerWidget(this));
    splitter->addWidget(new PlaylistsWidget(this));

    setCentralWidget(splitter);

    restoreWindowSize(KGlobal::config()->group("MainWindow"));
}

MainWindow::~MainWindow() {
    qDebug("MainWindow: destructor invoked");
}

bool MainWindow::queryClose() {
    saveWindowSize(KGlobal::config()->group("MainWindow"));
    emit mainWindowClosed();
    return true;
}
